package com.evil.application.api;

import com.evil.application.config.FeignErrorDecoder;
import com.evil.application.pojo.dto.form.control.ControlBaseInfoDTO;
import com.evil.application.pojo.dto.order.*;
import com.evil.application.pojo.dto.order.data.OrderRelatedDataMapReqDTO;
import com.evil.application.pojo.dto.order.data.TableRelatedDataPageReqDTO;
import com.evil.application.pojo.dto.process.node.NodeControlReqDTO;
import com.evil.application.pojo.dto.process.node.NodeControlRespDTO;
import com.evil.common.application.dto.order.OrderPageDataRespDTO;
import com.evil.common.application.dto.order.data.ControlDataDTO;
import com.evil.common.core.constant.ServiceNameConstant;
import com.evil.common.core.entity.QueryModel;
import com.github.pagehelper.PageInfo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;
import java.util.Map;

/**
 * 应用订单接口
 *
 * @author liyang
 * @date 2022-08-08 00:00
 */
@FeignClient(name = ServiceNameConstant.APPLICATION_SERVICE, configuration = {FeignErrorDecoder.class})
public interface RemoteApplicationOrderService {

    /**
     * 获取应用订单可见控件
     *
     * @param orderBaseReqDTO orderPageBaseReqDTO
     * @return List
     */
    @PostMapping("/remote/application/order/visible/control")
    List<ControlBaseInfoDTO> ordersVisibleControlsBase(@Validated @RequestBody OrderBaseReqDTO orderBaseReqDTO);

    /**
     * 获取节点控件
     *
     * @param nodeControlReqDTO nodeControlReqDTO
     * @return NodeControlRespDTO
     */
    @PostMapping("/remote/application/order/node/control")
    NodeControlRespDTO nodeControl(@Validated @RequestBody NodeControlReqDTO nodeControlReqDTO);

    /**
     * 提交应用订单
     *
     * @param pushOrderReqDTO addOrderReqDTO
     */
    @PostMapping("/remote/application/order/push")
    AddOrderRespDTO pushOrder(@Validated @RequestBody PushOrderReqDTO pushOrderReqDTO);

    /**
     * 新增应用订单
     *
     * @param addOrderReqDTO addOrderReqDTO
     * @return AddOrderRespDTO
     */
    @PostMapping("/remote/application/order/add")
    AddOrderRespDTO addOrder(@Validated @RequestBody AddOrderReqDTO addOrderReqDTO);

    /**
     * 编辑应用订单
     *
     * @param modifyOrderReqDTO modifyOrderReqDTO
     * @return AddOrderRespDTO
     */
    @PostMapping("/remote/application/order/modify")
    AddOrderRespDTO modifyOrder(@Validated @RequestBody ModifyOrderReqDTO modifyOrderReqDTO);

    /**
     * 批量编辑应用订单 （机器人）
     *
     * @param appOrdersControlDataDTO appOrdersControlDataDTO
     */
    @PostMapping("/remote/application/order/modify/batch")
    void modifyOrderBatch(@Validated @RequestBody AppOrdersControlDataDTO appOrdersControlDataDTO);

    /**
     * 应用订单流转
     *
     * @param completeOrderReqDTO completeOrderReqDTO
     */
    @PostMapping("/remote/application/order/complete")
    void completeOrder(@Validated @RequestBody CompleteOrderReqDTO completeOrderReqDTO);

    /**
     * 订单列表
     *
     * @param queryModel queryModel
     */
    @PostMapping("/remote/application/order/list")
    PageInfo<OrderPageDataRespDTO> orderList(@Validated @RequestBody QueryModel<OrderPageReqDTO> queryModel);

    /**
     * 订单统计
     *
     * @param orderStatisticsReqDTO orderStatisticsReqDTO
     * @return List
     */
    @PostMapping("/remote/application/order/statistics")
    List<OrderStatisticsRespDTO> orderStatistics(@Validated @RequestBody OrderStatisticsReqDTO orderStatisticsReqDTO);

    /**
     * 订单详情
     *
     * @param orderDetailReqDTO orderDetailReqDTO
     * @return OrderRespDTO
     */
    @PostMapping("/remote/application/order/detail")
    OrderDetailRespDTO orderDetail(@Validated @RequestBody OrderDetailReqDTO orderDetailReqDTO);

    /**
     * 转交
     *
     * @param orderReassignmentReqDTO orderPassOnReqDTO
     */
    @PostMapping("/remote/application/order/reassignment")
    void reassignment(@Validated @RequestBody OrderReassignmentReqDTO orderReassignmentReqDTO);

    /**
     * 删除订单
     *
     * @param deleteOrderReqDTO deleteOrderReqDTO
     */
    @PostMapping("/remote/application/order/delete")
    void deleteOrder(@Validated @RequestBody DeleteOrderReqDTO deleteOrderReqDTO);

    /**
     * 初始化应用订单数据（机器人创建订单）
     *
     * @param applicationId applicationId
     * @return InitControlDataDTO
     */
    @PostMapping("/remote/application/init/order/data")
    InitControlDataRespDTO initAppOrderData(@RequestParam("applicationId") Long applicationId);

    /**
     * 获取订单指定控件数据map
     *
     * @param queryModel queryModel
     * @return Map
     */
    @PostMapping("/remote/application/orders/data/map")
    Map<String, List<ControlDataDTO>> orderRelatedDataMap(@Validated @RequestBody QueryModel<OrderRelatedDataMapReqDTO> queryModel);

    /**
     * 表格关联数据page
     *
     * @param tableRelatedDataPageReqDTO tableRelatedDataPageReqDTO
     * @return PageInfo
     */
    @PostMapping("/remote/application/table/related/page")
    PageInfo<OrderPageDataRespDTO> tableRelatedDataPage(@Validated @RequestBody TableRelatedDataPageReqDTO tableRelatedDataPageReqDTO);
}
